#region Header

// MS codename Velocity Distributed Cache Extensions.
// (c) 2009

#endregion


#region Usings

using System;

using Caching.Extensions.Core.Impl;

#endregion


namespace Caching.Extensions.Core
{
    /// <summary>
    /// SmartCache factory.
    /// </summary>
    public class SmartCacheFactory
    {
        #region Private data

        private static ISmartCacheLocalStorage s_localCache;
        private static readonly object s_lock = new object();

        #endregion


        /// <summary>
        /// Gets the local cache storage.
        /// </summary>
        /// <returns></returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
            Justification="Should be method because uses explicit class instantiation")]
        protected ISmartCacheLocalStorage GetLocalStorage()
        {
            if (s_localCache != null)
                return s_localCache;

            lock (s_lock)
            {
                if (s_localCache == null)
                {
                    s_localCache = new InprocessCache(TimeSpan.FromMinutes(5));
                }
                return s_localCache;
            }
        }


        /// <summary>
        /// Gets the cache by name.
        /// </summary>
        /// <param name="name">The cache name.</param>
        /// <returns></returns>
        public ISmartCache GetCache(string name)
        {
            throw new NotImplementedException();
        }
    }
}